package com.qingcloud.adminbackend.entity.equipment;

import cn.hutool.core.util.StrUtil;
import com.qingcloud.adminbackend.entity.sensor.SysSensorFactorConfigDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 设备详细数据
 * </p>
 *
 * @author liyuhong
 * @since 2019-04-16
 */
@Data
public class SysEquipmentDetailsDTO implements Serializable {

    @ApiModelProperty(value = "设备信息id")
    private String id;
    /*设备基本信息*/
    @ApiModelProperty(value = "设备编号")
    private String equipmentId;

    @ApiModelProperty(value = "二维码")
    private String qrcode;

    @ApiModelProperty(value = "二维码图片名称")
    private String qrcodeImgName;

    @ApiModelProperty(value = "产品")
    private String product;

    @ApiModelProperty(value = "产品id")
    private Integer productId;

    @ApiModelProperty(value = "产品型号")
    private String productType;

    @ApiModelProperty(value = "应有监测因子")
    private String sensorFactors;

    @ApiModelProperty(value = "应有监测因子集合")
    private List<SysSensorFactorConfigDTO> factors;

    @ApiModelProperty(value = "传感器监测因子集合")
    private List<SysSensorFactorConfigDTO> sensors;

    @ApiModelProperty(value = "所属订单")
    private String orderName;

    @ApiModelProperty(value = "所属订单id")
    private String orderId;

    @ApiModelProperty(value = "设备状态")
    private String status;

    @ApiModelProperty(value = "设备状态")
    private String statusName;

    @ApiModelProperty(value = "设备运行模式")
    private String runningMode;

    @ApiModelProperty(value = " 验证状态")
    private String verifyStatus;

    @ApiModelProperty(value = " 设备种类")
    private String equipmentCatagory;

    @ApiModelProperty(value = "设备状态")
    private String equipmentCatagoryName;
    /*硬件信息*/
    @ApiModelProperty(value = "协议类型")
    private String protocolCoe;

    @ApiModelProperty(value = "生产厂商")
    private String manufacturer;

    @ApiModelProperty(value = "出厂时间")
    private String factoryTime;

    @ApiModelProperty(value = "物联网卡号")
    private String phoneNum;

    @ApiModelProperty(value = "ccid号码")
    private String ccidNum;

    @ApiModelProperty(value = "搜集间隔")
    private Integer collectInternel;

    @ApiModelProperty(value = "上传间隔")
    private Integer uploadInternel;

    @ApiModelProperty(value = "硬件版本号")
    private String hardwareVersion;

    @ApiModelProperty(value = "固件版本号（嵌入式程序版本号）")
    private String softwareVersion;

    @ApiModelProperty(value = "接收端IP地址")
    private String receiverIp;

    @ApiModelProperty(value = "经纬度")
    private String lngLat;

    @ApiModelProperty(value = "Led开关")
    private String ledStatus;

    @ApiModelProperty(value = "LED灯最大亮度")
    private String ledMaxBrigh;

    @ApiModelProperty(value = "蜂鸣器开关")
    private String buzzerStatus;

    @ApiModelProperty(value = "订单的业务类型")
    private String businessType;

    @ApiModelProperty(value = "是否设备管理权限(0无，1有)", example = "1")
    private int manageAuth;

    @ApiModelProperty(value = "是否设备读权限(0无，1有)", example = "1")
    private int readAuth;

    @ApiModelProperty(value = "在线控制（0：支持；1不支持）")
    private Integer onlineControl;

    @ApiModelProperty(value = "产品配置的生命周期")
    private Long cycle;

    @ApiModelProperty(value = "设备已使用生命周期数")
    private Long pollutionCount;

    @ApiModelProperty(value = "是否需要预热（0：是，1：否）",example = "0")
    private Integer ispreheat;

    public String getVerifyStatus() {
        if (StrUtil.isBlank(verifyStatus)) {
            return "";
        }
        //验证状态(1:未测试；2：生产测试完成，3：校准完成）
        switch (verifyStatus) {
            case "1":
                return "未测试";
            case "2":
                return "生产测试完成";
            case "3":
                return "校准完成";
        }
        return "";
    }

    public String getLedStatus() {
        if (StrUtil.isBlank(ledStatus)) {
            return "";
        }
        //Led开关(1:打开；0关闭）
        switch (ledStatus) {
            case "0":
                return "关闭";
            case "1":
                return "打开";
        }
        return "";
    }

    public String getBuzzerStatus() {
        if (StrUtil.isBlank(buzzerStatus)) {
            return "";
        }
        //蜂鸣器开关(1:打开；0关闭）
        switch (buzzerStatus) {
            case "0":
                return "关闭";
            case "1":
                return "打开";
        }
        return "";
    }
}
